Imports System.Web

Public Class cConf
    Private _praticanti As Boolean
    Private _sezioni As String
    Private _descAlbo As String
    Private _cooperativa As Boolean
    Private _laurea As Boolean
    Private _crediti As Boolean
    Private _storicoAttI As Boolean
    Private _specPrat As Boolean
    Private _sezione As String
    Private _totalePraticantato As Int16
    Private _giorniProf As Int16
    Private _giorniDitta As Int16
    Private _quotaIscritto As String
    Private _quotaPraticante As String




    Public Property praticanti() As Boolean
        Get
            Return _praticanti
        End Get
        Set(ByVal Value As Boolean)
            _praticanti = Value
        End Set
    End Property
    Public Property sezioni() As String
        Get
            Return _sezioni
        End Get
        Set(ByVal Value As String)
            _sezioni = Value
        End Set
    End Property
    Public Property sezione() As String
        Get
            Return _sezione
        End Get
        Set(ByVal Value As String)
            _sezione = Value
        End Set
    End Property
    Public Property descAlbo() As String
        Get
            Return _descAlbo
        End Get
        Set(ByVal Value As String)
            _descAlbo = Value
        End Set
    End Property
    Public Property cooperativa() As Boolean
        Get
            Return _cooperativa
        End Get
        Set(ByVal Value As Boolean)
            _cooperativa = Value
        End Set
    End Property
    Public Property laurea() As Boolean
        Get
            Return _laurea
        End Get
        Set(ByVal Value As Boolean)
            _laurea = Value
        End Set
    End Property
    Public Property crediti() As Boolean
        Get
            Return _crediti
        End Get
        Set(ByVal Value As Boolean)
            _crediti = Value
        End Set
    End Property
    Public Property storicoAttI() As Boolean
        Get
            Return _storicoAttI
        End Get
        Set(ByVal Value As Boolean)
            _storicoAttI = Value
        End Set
    End Property
    Public Property specPrat() As Boolean
        Get
            Return _specPrat
        End Get
        Set(ByVal Value As Boolean)
            _specPrat = Value
        End Set
    End Property
    Public Property totalePraticantato() As Int16
        Get
            Return _totalePraticantato
        End Get
        Set(ByVal Value As Int16)
            _totalePraticantato = Value
        End Set
    End Property
    Public Property giorniProf() As Int16
        Get
            Return _giorniProf
        End Get
        Set(ByVal Value As Int16)
            _giorniProf = Value
        End Set
    End Property
    Public Property giorniDitta() As Int16
        Get
            Return _giorniDitta
        End Get
        Set(ByVal Value As Int16)
            _giorniDitta = Value
        End Set
    End Property
    Public Property quotaIscritto() As String
        Get
            Return _quotaIscritto
        End Get
        Set(ByVal Value As String)
            _quotaIscritto = Value
        End Set
    End Property
    Public Property quotaPraticante() As String
        Get
            Return _quotaPraticante
        End Get
        Set(ByVal Value As String)
            _quotaPraticante = Value
        End Set
    End Property
End Class


Public Class cConfigura
    Dim _conf As cConf

    Public Sub New(Optional ByVal newInstance As Boolean = False)

        If (HttpContext.Current.Session("CONFIGURA") Is Nothing Or newInstance) Then
            ' new instance here ;)
            _conf = New cConf
            HttpContext.Current.Session("CONFIGURA") = _conf
        Else
            _conf = HttpContext.Current.Session("CONFIGURA")
        End If
    End Sub

    Public Property conf() As cConf
        Get
            Return _conf
        End Get
        Set(ByVal Value As cConf)
            _conf = Value
        End Set
    End Property

    Public Function checkMultiAlbo() As String
        Dim xmlDoc As New System.Xml.XmlDocument

        xmlDoc.Load(HttpContext.Current.Server.MapPath("") & "\configura.xml")
        Return xmlDoc.DocumentElement.SelectSingleNode("multi").InnerText

    End Function

    Public Function elencoAlbi() As DataTable
        Dim sql As String = "select id, albo from albi where id in (" & checkMultiAlbo() & ") order by albo"
        Return (New Connessione).getDataTable(sql)
    End Function

    Public Sub leggiXmlFarmacisti()
        Dim xmlDoc As New System.Xml.XmlDocument
        Dim nodo As System.Xml.XmlNode

        xmlDoc.Load(HttpContext.Current.Server.MapPath("") & "\configura.xml")
        nodo = xmlDoc.DocumentElement.SelectSingleNode("albi").SelectSingleNode("albo_" & HttpContext.Current.Session("albo"))

        conf.praticanti = nodo.SelectSingleNode("praticanti").InnerText
        conf.sezioni = nodo.SelectSingleNode("sezioni").InnerText
        conf.descAlbo = nodo.SelectSingleNode("descAlbo").InnerText
        conf.cooperativa = nodo.SelectSingleNode("cooperativa").InnerText
        conf.laurea = nodo.SelectSingleNode("laurea").InnerText
        conf.crediti = nodo.SelectSingleNode("crediti").InnerText
        conf.storicoAttI = nodo.SelectSingleNode("storicoAttI").InnerText
        conf.specPrat = nodo.SelectSingleNode("specPrat").InnerText
        conf.totalePraticantato = nodo.SelectSingleNode("totalePraticantato").InnerText
        conf.giorniDitta = nodo.SelectSingleNode("giorniDitta").InnerText
        conf.giorniProf = nodo.SelectSingleNode("giorniProf").InnerText
        conf.quotaIscritto = nodo.SelectSingleNode("quotaIscritto").InnerText
        conf.quotaPraticante = nodo.SelectSingleNode("quotaPraticante").InnerText

    End Sub

    Public Sub leggiXmlPeriti()
        Dim xmlDoc As New System.Xml.XmlDocument
        Dim nodo As System.Xml.XmlNode


        xmlDoc.Load(HttpContext.Current.Server.MapPath("") & "\configura.xml")
        nodo = xmlDoc.DocumentElement.SelectSingleNode("albi").SelectSingleNode("albo_" & HttpContext.Current.Session("albo"))

        conf.praticanti = nodo.SelectSingleNode("praticanti").InnerText
        conf.sezioni = nodo.SelectSingleNode("sezioni").InnerText
        conf.descAlbo = nodo.SelectSingleNode("descAlbo").InnerText
        conf.cooperativa = nodo.SelectSingleNode("cooperativa").InnerText
        conf.laurea = nodo.SelectSingleNode("laurea").InnerText
        conf.crediti = nodo.SelectSingleNode("crediti").InnerText
        conf.storicoAttI = nodo.SelectSingleNode("storicoAttI").InnerText
        conf.specPrat = nodo.SelectSingleNode("specPrat").InnerText

    End Sub

End Class
